﻿using System.Collections.Specialized;
using System.Collections.Generic;

namespace Phone.Framework
{
    public static class ApplicationCache
    {
        private static readonly Dictionary<object, object> _dictionary = new Dictionary<object, object>();

        public static T Get<T>(object key)
        {
            if (_dictionary.ContainsKey(key))
                return (T)_dictionary[key];
            return default(T);
        }

        public static object Get(object key)
        {
            return _dictionary[key];
        }

        public static void Set(object key, object value)
        {
            _dictionary[key] = value;
        }

        public static void Set<T>(object key, T value)
        {
            _dictionary[key] = value;
        }

        public static void Add(object key, object value)
        {
            _dictionary.Add(key, value);
        }

        public static void Remove(object key)
        {
            _dictionary.Remove(key);
        }

        public static bool Contains(object key)
        {
            return _dictionary.ContainsKey(key);
        }

        public static void Clear()
        {
            _dictionary.Clear();
        }
    }
}
